package com.group01.validation;

import com.group01.annotation.Chinese;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ChineseValidation implements ConstraintValidator<Chinese, String> {


    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        String regex = "^[\u4e00-\u9fa5]";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(value);
        return matcher.find();
    }
}
